package logic

import (
	_ "github.com/lib/pq"

	"context"

	"go-zero-demo-3/mall/user/api/internal/svc"
	"go-zero-demo-3/mall/user/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type RegisterLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewRegisterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisterLogic {
	return &RegisterLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *RegisterLogic) Register(req *types.RegisterRequest) (resp *types.RegisterResponse, err error) {
	_, err = l.svcCtx.StudentModel.FindOne(l.ctx, req.StudentID)
	if err != nil {
		return nil, err
	}

	return &types.RegisterResponse{
		Result: "2",
	}, nil
}
